<template lang="html">
  <div class="myProjectArrange">
    <tabs :value="tabsName" @on-click="tabsClick">
      <TabPane label="待分配" name="load">
        <card>
          <p slot="title">待分配</p>
          <Table border :loading="loading" :columns="loadColumns" :data="listDatas"></Table>
          <Row>
            <Col span="24">
            <Page @on-change="changePage" :total="total" style="float: right;padding-top: 10px" />
            </Col>
          </Row>
        </card>
      </TabPane>
      <TabPane label="已分配" name="allow">
        <card>
          <p slot="title">已分配</p>
          <Table border :loading="loading" :columns="allowColumns" :data="listDatas"></Table>
          <Row>
            <Col span="24">
            <Page @on-change="changePage" :total="total" style="float: right;padding-top: 10px" />
            </Col>
          </Row>
        </card>
      </TabPane>
    </tabs>

    <!-- 工程师库 -->
    <Modal title="工程师库" v-model="engineerModel" width="800" class-name="vertical-center-modal">
      <Table highlight-row :loading="engineerLoad" :columns="engineerColumns" :data="engineerListData"></Table>
      <Page style="margin-top: 10px;" @on-change="getEengineerlList" :total="engineerTotal" />
    </Modal>

    <!-- 人员库 -->
    <Modal title="人员库" v-model="personnelModel" width="800" class-name="vertical-center-modal">
      <Table highlight-row :loading="personnelLoad" :columns="personnelColumns" :data="personnelListData"></Table>
      <Page style="margin-top: 10px;" @on-change="getPersonnelList" :total="personnelTotal" />
    </Modal>

    <!-- 一审二审 -->
    <Modal title="一审二审人员库" v-model="YEModel" width="800" class-name="vertical-center-modal">
      <Table highlight-row :loading="personnelLoad" :columns="YEColumns" :data="personnelListData"></Table>
      <Page style="margin-top: 10px;" @on-change="getPersonnelList" :total="personnelTotal" />
    </Modal>

    <Modal title="项目分配" v-model="allocationModal" class-name="vertical-center-modal" :loading="allocationModalLoading" >
      <Form :model="info_data" label-position="right" :label-width="100" ref="info_data" :rules="ruleValidate">
        <FormItem v-if="label_names['项目负责人']" label="项目负责人" prop="Perject_leader_lable">
          <Input v-model="info_data.Perject_leader_lable" @on-focus="show('gcs', 'Perject_leader_lable', 'Perject_leader')"></Input>
          <p style="text-align:right">&nbsp;</p>
        </FormItem>
        <!-- 有项目负责人情况下会有项目组成员 -->
        <FormItem v-if="label_names['项目负责人']" label="项目组成员" prop="Staff_name_lable">
          <Input v-model="info_data.Staff_name_lable" @on-focus="show('ry', 'Staff_name_lable', 'Staff_name')"></Input>
          <p style="text-align:right">&nbsp;</p>
        </FormItem>
        <FormItem v-if="label_names['一审人员']" label="一审人员" prop="Ysname_lable">
          <Input v-model="info_data.Ysname_lable" @on-focus="show('YE', 'Ysname_lable', 'Ysname')"></Input>
          <p style="text-align:right">&nbsp;</p>
        </FormItem>
        <FormItem v-if="label_names['二审人员']" label="二审人员" prop="Esname_lable">
          <Input v-model="info_data.Esname_lable" @on-focus="show('YE', 'Esname_lable', 'Esname')"></Input>
          <p style="text-align:right">&nbsp;</p>
        </FormItem>
        <FormItem v-if="label_names['初审工程师']" label="初审工程师" prop="Cname_lable">
          <Input v-model="info_data.Cname_lable" @on-focus="show('gcs', 'Cname_lable', 'Cname')"></Input>
          <p style="text-align:right">&nbsp;</p>
        </FormItem>
        <FormItem v-if="label_names['复审工程师']" label="复审工程师" prop="Fname_lable">
          <Input v-model="info_data.Fname_lable" @on-focus="show('gcs', 'Fname_lable', 'Fname')"></Input>
          <p style="text-align:right">&nbsp;</p>
        </FormItem>
        <FormItem v-if="label_names['终审工程师']" label="终审工程师" prop="Zname_lable">
          <Input v-model="info_data.Zname_lable" @on-focus="show('gcs', 'Zname_lable', 'Zname')"></Input>
          <p style="text-align:right">&nbsp;</p>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" @click="allocationModal = false">取消</Button>
        <Button type="primary"  @click="submitFP" :disabled="unChangeStatus">确定</Button>
      </div>
    </Modal>


  </div>
</template>

<script>
export default {
  data() {
    return {
      // tabsName: 'allow',
      tabsName: 'load',
      listDatas: [],
      loading: true,
      total: 0,
      bcode: 'z',
      personnels1:[],
      allocationModal: false,

      info_data: {
        Perject_name: ''
      },
      ruleValidate: {
        Perject_leader_lable: {required: true, message: '项目负责人不能为空', trigger: 'blur'},
        Staff_name_lable: {required: true, message: '项目组成员不能为空', trigger: 'blur'},
        Ysname_lable: {required: true, message: '一审人员不能为空', trigger: 'blur'},
        Esname_lable: {required: true, message: '二审人员不能为空', trigger: 'blur'},
        Cname_lable: {required: true, message: '初审工程师不能为空', trigger: 'blur'},
        Fname_lable: {required: true, message: '复审工程师不能为空', trigger: 'blur'},
        Zname_lable: {required: true, message: '终审工程师不能为空', trigger: 'blur'},
      },

      project_number: '',
      Project_id: 0,

      changeInfo: {},
      lastSubmitValue: {},
      allocationModalLoading: true,

      unChangeStatus: true,

      // 待分配
      loadColumns: [
        { title: '序号', type: 'index', width: 60, align: 'center' },
        { title: '项目名称', key: 'ProjectName', width: 220, align: 'center' },
        { title: '公司级别', key: 'project_level_name', align: 'center' },
        { title: '报告类型', key: 'ReportType', align: 'center' },
        { title: '地区', key: 'BuildAddress', align: 'center' },
        { title: '提交人', key: 'CommitName', align: 'center' },
        { title: '项目负责人', key: 'leaderName', align: 'center' },
        { title: '项目组成员', key: 'StaffNames', align: 'center' },
        { title: '审核人员', key: 'Auditors', align: 'center' },
        { title: '操作', key: 'opera', align: 'center', render: (h, params) => {
            return h("div", [
              h(
                "Button", {
                  props: {
                    type: "primary",
                    size: "small"
                  },
                  on: {
                    click: () => {
                      this.resetFields()
                      let project_level = params.row.ProjectLevel,
                          tof = params.row.Tof,
                          IsFcAssign = params.row.IsFcAssign,
                          Project_name = params.row.ProjectName
                      this.setGcsOption(project_level, tof,Project_name)

                      this.engineerSelectData = []
                      this.personnelSelectData = []

                      this.Project_id = params.row.Id

                      this.info_data = {}
                      this.YEData = []
                      this.allocationModal = true
                    }
                  }
                },
                "分配"
              )
            ]);
          }
        }
      ],
      loadInfo: [],

      // 已分配
      allowColumns: [
        { title: '序号', type: 'index', width: 60, align: 'center' },
        { title: '项目名称', key: 'projectName', width: 220, align: 'center' },
        { title: '公司级别', key: 'project_level_name', align: 'center' },
        { title: '报告类型', key: 'reportType', align: 'center' },
        { title: '地区', key: 'buildAddress', align: 'center' },
        { title: '提交人', key: 'commitName', align: 'center' },
        { title: '项目负责人', key: 'leaderName', align: 'center' },
        { title: '项目组成员', key: 'staffNames', align: 'center' },
        { title: '审核人员', key: 'auditors', align: 'center' },
        { title: '操作', key: 'opera', align: 'center', render: (h, params) => {
            return h("div", [
              h(
                "Button", {
                  props: {
                    type: "primary",
                    size: "small"
                  },
                  on: {
                    click: () => {
                      this.resetFields()
                      this.info_data.Perject_name = params.row.project_name
                      this.Project_id = params.row.id

                      let info = params.row,
                          personnelSelectData = {},
                          Staff_name = [],
                          Staff_name_number = info.staffNameIds,
                          auditors_ids = info.auditorsId,
                          project_level = info.projectLevel,
                          tof = info.tof,
                          IsFcAssign = info.isFcAssign,
                          engineerSelectData = [],
                          leader_name_id = info.leaderNameId,
                          datas = [],
                          engineers1 = this.engineers1,
                          personnels1 = this.personnels1,
                          YEData = [],
                          yname_id = Number(auditors_ids['一审']),
                          ename_id = Number(auditors_ids['二审']),
                          cname_id = Number(auditors_ids['初审']),
                          fname_id = Number(auditors_ids['复审']),
                          zname_id = Number(auditors_ids['终审'])

                      this.setGcsOption(project_level, tof,params.row.projectName)
                      // 对于项目组成员
                      if (Staff_name_number) {
                        Staff_name_number.split(',').forEach((value) => {
                          let number = Number(value)
                          personnelSelectData[number] = true
                          Staff_name.push(number)
                        })
                      }
                      datas = {
                        // 项目组成员
                        Staff_name_lable: info.staffNames,
                        Staff_name: Staff_name.join(','),

                        // 项目负责人
                        Perject_leader_lable: info.leaderName,
                        Perject_leader: leader_name_id,

                        // 一审
                        Ysname_lable: personnels1[yname_id],
                        Ysname: yname_id,

                        // 二审
                        Esname_lable: personnels1[ename_id],
                        Esname: ename_id,

                        // 初审工程师
                        Cname_lable: engineers1[cname_id],
                        Cname: cname_id,

                        // 复审工程师
                        Fname_lable: engineers1[fname_id],
                        Fname: fname_id,

                        // 终审工程师
                        Zname_lable: engineers1[zname_id],
                        Zname: zname_id,
                      },
                      engineerSelectData[leader_name_id] = '项目负责人'
                      engineerSelectData[cname_id] = '初审工程师'
                      engineerSelectData[fname_id] = '复审工程师'
                      engineerSelectData[zname_id] = '终审工程师'

                      YEData[yname_id] = '一审人员'
                      YEData[ename_id] = '二审人员'

                      this.YEData = YEData

                      this.personnelSelectData = personnelSelectData
                      this.engineerSelectData = engineerSelectData

                      this.unChangeStatus = true
                      this.info_data = datas
                      this.allocationModal = true
                    }
                  }
                },
                "编辑"
              )
            ]);
          }
        }
      ],
      allowInfo: [],

      // 工程师
      engineerLoad: false,
      engineerModel: false,
      engineerColumns: [
        { title: '序号', key: 'member', align: 'center' },
        { title: '姓名', key: 'userName' },
        { title: '登记证号', key: 'regNumber' },
        { title: '登记类别', key: 'registerClass' },
        { title: '现有项目数量', key: 'projectNumber' },
        { title: '审核项目数', key: 'projectNumbers'},
        { title: '操作', align: 'center', key: 'select', render: (h, params) => {
            return h('div', [
              h('Select', {
                  props: {
                    value: this.engineerSelectData[params.row.member],
                    placeholder: '无选项'
                  },
                  on: {
                    'on-change': (e) => {
                      if (!e) {
                        return
                      }
                      let engineerSelectData = this.engineerSelectData,
                        userName = params.row.userName,
                        member = params.row.member,
                        info = this.changeInfo

                      engineerSelectData.forEach((value, key) => {
                        if (value === e) {
                          engineerSelectData[key] = null
                          Vue.set(this.engineerSelectData, key, null)
                        }
                      });

                      engineerSelectData[member] = e
                      setTimeout(() => {
                        Vue.set(this.engineerSelectData, member, e)
                        this.$refs.info_data.validate()
                      }, 10)

                      engineerSelectData.forEach((select_info, select_key) => {
                        if (select_info === e) {
                          let input_name = this.label_names[select_info]
                          this.info_data[input_name + '_lable'] = userName
                          this.info_data[input_name] = member
                        }
                      })

                      this.unChangeStatus = false

                    }
                  }
                },
                this.gcsOption.map(e => {
                  let is_show = e.show

                  if (is_show === false) {
                    return false
                  }

                  return h('Option', {
                    props: {
                      value: e.label
                    }
                  }, e.label);
                })
              )
            ]);
          }
        }
      ],
      gcsOption: [],
      gcsOption_z_z_4: [
        { label: '项目负责人', value: '1', input_name: 'Perject_leader' },
        { label: '初审工程师', value: '2', input_name: 'Cname' },
        { label: '复审工程师', value: '3', input_name: 'Fname' },
        { label: '终审工程师', value: '4', input_name: 'Zname' },
      ],
      gcsOption_z_z_6: [
        { label: '项目负责人', value: '1', input_name: 'Perject_leader' },
        { label: '一审人员', value: '2', input_name: 'Ysname', show: false, },
        { label: '二审人员', value: '3', input_name: 'Esname', show: false, },
        { label: '初审工程师', value: '4', input_name: 'Cname' },
        { label: '复审工程师', value: '5', input_name: 'Fname' },
        { label: '终审工程师', value: '6', input_name: 'Zname' },
      ],
      gcsOption_z_f_3: [
        { label: '初审工程师', value: '1', input_name: 'Cname' },
        { label: '复审工程师', value: '2', input_name: 'Fname' },
        { label: '终审工程师', value: '3', input_name: 'Zname' },
      ],
      gcsOption_f_f_3: [
        { label: '项目负责人', value: '1', input_name: 'Perject_leader' },
        { label: '一审人员', value: '2', input_name: 'Ysname', show: false, },
        { label: '二审人员', value: '3', input_name: 'Esname', show: false, },
      ],
      gcsOption_f_f_1: [
        { label: '项目负责人', value: '1', input_name: 'Perject_leader' },
      ],
      engineerListData: [],
      engineerTotal: 0,
      engineers: [],
      personnels: [],

      // 人员库
      personnelLoad: true,
      personnelModel: false,
      personnelColumns: [
        { title: '序号', key: 'Member', align: 'center' },
        { title: '姓名', key: 'FullName' },
        { title: '登记证号', key: 'JobCompany' },
        { title: '登记类别', key: 'zongshu' },
        { title: '现有项目数量', key: 'fenshuliang' },
        { title: '操作', align: 'center', render: (h, params) => {
            let info = this.changeInfo
            return h('div', [
              h('Checkbox', {
                props: {
                  value: this.personnelSelectData[params.row.Member]
                },
                on: {
                  'on-change': (event) => {
                    let Member = params.row.Member,
                      FullName = params.row.FullName,
                      Members = this.info_data[info.name],
                      FullNames = this.info_data[info.input_name]
                   
                    if (!Members) {
                      Members = []
                      FullNames = []
                    } else {
                      Members = Members.toString().split(',')
                      FullNames = FullNames.toString().split(',')
                    }

                    if (event) {
                      Members.push(Member)
                      FullNames.push(FullName)
                    } else {
                      Members.remove(Member)
                      FullNames.remove(FullName)
                    }

                    Members = Members.join(',')
                    FullNames = FullNames.join(',')

                    this.info_data[info.name] = Members
                    this.info_data[info.input_name] = FullNames

                    this.lastSubmitValue['select'] = Members
                    this.lastSubmitValue['select_lable'] = FullNames

                    setTimeout(() => {
                      Vue.set(this.personnelSelectData, Member, event)
                      this.$refs.info_data.validate()
                    }, 10)
                    
                    this.unChangeStatus = false
                  }
                },
              })
            ]);
          }
        }
      ],
      personnelListData: [],
      personnelTotal: 0,

      // 一审二审
      YEModel: false,
      YEColumns: [
        { title: '序号', key: 'Member', align: 'center' },
        { title: '姓名', key: 'FullName' },
        { title: '登记证号', key: 'JobCompany' },
        { title: '登记类别', key: 'zongshu' },
        { title: '现有项目数量', key: 'fenshuliang' },
        { title: '操作', align: 'center', render: (h, params) => {

            return h('div', [
              h('Select', {
                  props: {
                    value: this.YEData[params.row.Member],
                    placeholder: '无选项'
                  },
                  on: {
                    'on-change': (e) => {
                      if (!e) {
                        return
                      }
                      let info = this.changeInfo,
                          YEData = this.YEData,
                          name = info.name,
                          input_name = info.input_name,
                          Member = params.row.Member,
                          FullName = params.row.FullName

                      YEData.forEach((value, key) => {
                        if (value === e) {
                          YEData[key] = null
                          Vue.set(this.YEData, key, null)
                        }
                      });

                      YEData[Member] = e
                      setTimeout(() => {
                        Vue.set(this.YEData, Member, e)
                        this.$refs.info_data.validate()
                      }, 10)

                      YEData.forEach((select_info, select_key) => {
                        if (select_info === e) {
                          let input_name = this.label_names[select_info]
                          this.info_data[input_name + '_lable'] = FullName
                          this.info_data[input_name] = Member
                        }
                      })

                      this.unChangeStatus = false
                    }
                  }
                },
                ['一审人员', '二审人员'].map(value => {
                  return h('Option', {
                    props: {
                      value,
                    }
                  }, value)
                })
              )
            ]);
          }
        }
      ],
      YEData: [],

      engineerSelectData: [],
      personnelSelectData: [],
      label_names: {},
      projectName: '',
    }
  },
  mounted() {
    this.getEengineerlList(1)
    this.getPersonnelList(1)
    this.tabsClick(this.tabsName)
  },
  methods: {
    getEengineerlList(page) {
      this.engineerLoad = true
      this.$post('assignjobs.showEngineer', {
          PageIndex: page - 1,
          Type: 1
      }).then((res) => {
        this.engineerListData = res.data
        this.engineerTotal = res.total
        // console.log(res.data1);
        this.engineerLoad = false
        let engineers = []
        let engineers1 = []
        res.data.forEach((value) => {
          engineers[value.member] = value.userName
        })
        res.data1.forEach((value) => {
          engineers1[value.member] = value.userName
        })
        this.engineers = engineers
        this.engineers1 = engineers1
      })
    },
    getPersonnelList(page) {
      this.personnelLoad = true
      this.$post('assignjobs.showEngineer', {
          PageIndex: page - 1
      }).then((res) => {
        this.personnelListData = res.data
        this.personnelTotal = res.count
        this.personnelLoad = false
        // console.log(res.data1);
        let personnels = []
        let personnels1 = []
        res.data.forEach((value) => {
          personnels[value.Member] = value.FullName
        })
        res.data1.forEach((value) => {
          personnels1[value.Member] = value.FullName
        })
        this.personnels = personnels
        this.personnels1 = personnels1
      })
    },
    tabsClick(name) {
      if (name == 'allow') {
        this.unChangeStatus = true
      } else {
        this.unChangeStatus = false
      }
      this.resetFields()
      this.listDatas = []
      this.tabsName = name
      this.getList(1)
    },
    getList(page) {
      this.loading = true
      // 对于 isAssign 待分配为空 已分配 1
      let IsAssign = this.tabsName === 'load' ? null : 1
      axios.get('/assignjobs/showFCProject', {
        params: {
          PageIndex: page,
          IsAssign,
        }
      }).then((res) => {
        this.bcode = res.bcode
        this.listDatas = res.data
        let listDatas = this.listDatas
        if(listDatas){
          listDatas.forEach(e => {
          if (e.ProjectLevel === '0' || e.projectLevel === '0') {
            e['project_level_name'] = '总公司'
          } else {
            e['project_level_name'] = '分公司'
          }
        });
        }


        this.total = res.count
        this.loading = false
      })
    },
    changePage(page) {
      this.getList(page)
    },
    setGcsOption(project_level, tof,project_name) {
      // 0 总公司 1 分公司
      this.projectName = project_name
      let gcsOption = null,
          label_names = []
      if (this.bcode == 'z') {
        // 总项目
        if (project_level == 0) {
          if (tof == 0) {
            gcsOption = this.gcsOption_z_z_4
          } else {
            gcsOption = this.gcsOption_z_z_6
          }
        } else {
          gcsOption = this.gcsOption_z_f_3
        }
      } else {
        if (tof == 0) {
          gcsOption = this.gcsOption_f_f_1
        } else {
          gcsOption = this.gcsOption_f_f_3
        }
      }
      gcsOption.forEach((option_value, option_key) => {
        let label = option_value.label,
            input_name = option_value.input_name

        label_names[label] = input_name
      })
      this.label_names = label_names

      this.gcsOption = gcsOption
    },
    show(type, input_name, name) {
      this.changeInfo = {
        input_name,
        name,
      }

      switch (type) {
        case 'gcs':
          this.engineerModel = true
          break;

        case 'ry':
          this.personnelModel = true
          break;

        default:
          this.YEModel = true
      }
    },
    // 提交
    submitFP() {
      this.$refs.info_data.validate(valid => {
        if (!valid) {
          this.$Message.error('不能为空')
          this.allocationModalLoading = false
          setTimeout(() => {
            this.allocationModalLoading = true
          }, 1)
        } else {

          this.$Message.info('正在更新中')

          let info = []
          let dataInfo = {}
          // info = this.info_data
          dataInfo.PerjectLeader = this.info_data.Perject_leader
          dataInfo.Cname = this.info_data.Cname
          dataInfo.Fname = this.info_data.Fname
          dataInfo.Zname = this.info_data.Zname
          dataInfo.StaffName = this.info_data.Staff_name
          dataInfo.Yname = this.info_data.Ysname
          dataInfo.Ename = this.info_data.Esname
          dataInfo.ProjectId = this.Project_id
          info = dataInfo
          
          if (this.tabsName === 'allow') {
            // 已分配 修改
            axios.get('/assignjobs/doagain', {
              params: info
            }).then((res) => {
              
              if (res._STATUS) {
                if(info.Yname){
                  social({
                    method: 'post',
                    url: '/info/notice',
                    params: {
                      content: '根据项目分配结果，您作为'+ this.projectName +'项目一审，请关注项目情况！',
                      type: info.Yname+'',
                      app_name: '环评管控系统',
                      app: 'eao',
                      uid: -1
                    },
                  })
                }
                if(info.Ename){
                  social({
                    method: 'post',
                    url: '/info/notice',
                    params: {
                      content: '根据项目分配结果，您作为'+ this.projectName +'项目二审，请关注项目情况！',
                      type: info.Ename+'',
                      app_name: '环评管控系统',
                      app: 'eao',
                      uid: -1
                    },
                  })
                }
                if(info.Cname){
                  social({
                    method: 'post',
                    url: '/info/notice',
                    params: {
                      content: '根据项目分配结果，您作为'+ this.projectName +'项目初审，请关注项目情况！',
                      type: info.Cname+'',
                      app_name: '环评管控系统',
                        app: 'eao',
                        uid: -1
                    },
                  })
                }
                if(info.Fname){
                  social({
                    method: 'post',
                    url: '/info/notice',
                    params: {
                      content: '根据项目分配结果，您作为'+ this.projectName +'项目复审，请关注项目情况！',
                      type: info.Fname+'',
                      app_name: '环评管控系统',
                        app: 'eao',
                        uid: -1
                    },
                  })
                }
                if(info.Zname){
                  social({
                    method: 'post',
                    url: '/info/notice',
                    params: {
                      content: '根据项目分配结果，您作为'+ this.projectName +'项目终审，请关注项目情况！',
                      type: info.Zname+'',
                      app_name: '环评管控系统',
                        app: 'eao',
                        uid: -1
                    },
                  })
                }
                if(info.StaffName){
                  social({
                    method: 'post',
                    url: '/info/notice',
                    params: {
                      content: '根据项目分配结果，您作为'+ this.projectName +'项目组成员，请关注项目情况！',
                      type: info.StaffName+'',
                      app_name: '环评管控系统',
                      app: 'eao',
                      uid: -1
                    },
                  }).then((res)=>{console.log(res)})
                }
                if(info.PerjectLeader){
                  social({
                    method: 'post',
                    url: '/info/notice',
                    params: {
                      content: '根据项目分配结果，您作为'+ this.projectName +'项目负责人，请关注项目情况！',
                      type: info.PerjectLeader+'',
                      app_name: '环评管控系统',
                      app: 'eao',
                      uid: -1
                    },
                  }).then((res)=>{console.log(res)})
                }
                this.allocationModal = false
                this.$Message.info(res._MESSAGE)
                this.getList(1)
              } else {
                this.$Message.error(res._MESSAGE)
                this.allocationModalLoading = false
                setTimeout(() => {
                  this.allocationModalLoading = true
                }, 1)
              }
            })
          } else {
            // 待分配 提交
            if (this.bcode == 'z') {
              // 总公司
              axios.get('/assignjobs/doassignjobs', {
                params: info,
              }).then((res) => {
                if (res._STATUS) {
                  if(info.Yname){
                    social({
                      method: 'post',
                      url: '/info/notice',
                      params: {
                        content: '根据项目分配结果，您作为'+ this.projectName +'项目一审，请关注项目情况！',
                        type: info.Yname+'',
                        app_name: '环评管控系统',
                        app: 'eao',
                        uid: -1
                      },
                    }).then((res)=>{console.log(res)})
                  }
                  if(info.Ename){
                    social({
                      method: 'post',
                      url: '/info/notice',
                      params: {
                        content: '根据项目分配结果，您作为'+ this.projectName +'项目二审，请关注项目情况！',
                        type: info.Ename+'',
                        app_name: '环评管控系统',
                        app: 'eao',
                        uid: -1
                      },
                    }).then((res)=>{console.log(res)})
                  }
                  social({
                    method: 'post',
                    url: '/info/notice',
                    params: {
                      content: '根据项目分配结果，您作为'+ this.projectName +'项目初审，请关注项目情况！',
                      type: info.Cname+'',
                      app_name: '环评管控系统',
                        app: 'eao',
                        uid: -1
                    },
                  }).then((res)=>{console.log(res)})
                  social({
                    method: 'post',
                    url: '/info/notice',
                    params: {
                      content: '根据项目分配结果，您作为'+ this.projectName +'项目复审，请关注项目情况！',
                      type: info.Fname+'',
                      app_name: '环评管控系统',
                        app: 'eao',
                        uid: -1
                    },
                  }).then((res)=>{console.log(res)})
                  social({
                    method: 'post',
                    url: '/info/notice',
                    params: {
                      content: '根据项目分配结果，您作为'+ this.projectName +'项目终审，请关注项目情况！',
                      type: info.Zname+'',
                      app_name: '环评管控系统',
                        app: 'eao',
                        uid: -1
                    },
                  }).then((res)=>{console.log(res)})
                  if(info.StaffName){
                    social({
                      method: 'post',
                      url: '/info/notice',
                      params: {
                        content: '根据项目分配结果，您作为'+ this.projectName +'项目组成员，请关注项目情况！',
                        type: info.StaffName+'',
                        app_name: '环评管控系统',
                        app: 'eao',
                        uid: -1
                      },
                    }).then((res)=>{console.log(res)})
                  }
                  if(info.PerjectLeader){
                    social({
                      method: 'post',
                      url: '/info/notice',
                      params: {
                        content: '根据项目分配结果，您作为'+ this.projectName +'项目负责人，请关注项目情况！',
                        type: info.PerjectLeader+'',
                        app_name: '环评管控系统',
                        app: 'eao',
                        uid: -1
                      },
                    }).then((res)=>{console.log(res)})
                  }
                  this.allocationModal = false
                  this.$Message.info(res._MESSAGE)
                  this.getList(1)
                } else {
                  this.$Message.error(res._MESSAGE)
                  this.allocationModalLoading = false
                  setTimeout(() => {
                    this.allocationModalLoading = true
                  }, 1)
                }

              })
            } else {
              // 分公司
              axios.get('/assignjobs/setFCompany', {
                params: info,
              }).then(res => {
                social({
                  method: 'post',
                  url: '/info/notice',
                  params: {
                    content: '根据项目分配结果，您作为'+ this.projectName +'项目组成员，请关注项目情况！',
                    app_name: '环评管控系统',
                    app: 'eao',
                    type: info.StaffName+'',
                    uid: -1
                  },
                })
                social({
                  method: 'post',
                  url: '/info/notice',
                  params: {
                    content: '根据项目分配结果，您作为'+ this.projectName +'项目负责人，请关注项目情况！',
                    app_name: '环评管控系统',
                    app: 'eao',
                    type: info.PerjectLeader+'',
                    uid: -1
                  },
                })
                if(info.Yname){
                  social({
                    method: 'post',
                    url: '/info/notice',
                    params: {
                      content: '根据项目分配结果，您作为'+ this.projectName +'项目一审，请关注项目情况！',
                      app_name: '环评管控系统',
                      app: 'eao',
                      type: info.Yname+'',
                      uid: -1
                    },
                  })
                }
                if(info.Ename){
                  social({
                    method: 'post',
                    url: '/info/notice',
                    params: {
                      content: '根据项目分配结果，您作为'+ this.projectName +'项目二审，请关注项目情况！',
                      app_name: '环评管控系统',
                      app: 'eao',
                      type: info.Ename+'',
                      uid: -1
                    },
                  })
                }
                 this.allocationModal = false
                let title = res._MESSAGE
                if (res._STATUS == 1) {
                  axios.post('member/findByMembers',{
                    charge: 1
                  }).then((res)=>{
                    var members = res.members
                    if(!(members==null||members=="")) {
                    // members = members.split(',')
                      console.log(members)
                      social({
                        method: 'post',
                        url: '/info/notice',
                        params: {
                          content: this.projectName + '项目需要分配审核工程师，请尽快分配！',
                          app_name: '环评管控系统',
                          app: 'eao',
                          type: members+'',
                          uid: -1
                        },
                      })
                    }
                  }).catch((err)=>{
                    console.log(err)
                  })
                  this.$Message.success({
                    content: title,
                    duration: 2
                  })
                  this.getList(1)
                } else {
                  this.$Message.error({
                    content: title,
                    duration: 2
                  })
                }
              })
            }
          }
        }
      })
    },

    // resetFields
    resetFields() {
      this.$refs.info_data.resetFields()
    },
  },
}
</script>

<style lang="less">
  .vertical-center-modal {
    display: flex;
    align-items: center;
    justify-content: center;

    .ivu-modal {
      top: 0;
    }
  }

  .principal {
    background: yellow;
  }
</style>
